import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  linkActiveClass: 'active',
  linkExactActiveClass: 'exact-active',
  routes: [

    /* 排盘 */

    {
      path: '/',
      redirect: '/paipan/bazi',
      component: () => import('@/views/paipan/XuanBaZiViews.vue'),
    },

    // 八字排盘
    {
      path: '/paipan/bazi',
      component: () => import('@/views/paipan/XuanBaZiViews.vue')
    },

    // 六爻排盘
    {
      path: '/paipan/liuyao',
      component: () => import('@/views/paipan/XuanLiuYaoViews.vue')
    },

    // 奇门排盘
    {
      path: '/paipan/qimen',
      component: () => import('@/views/paipan/XuanQiMenViews.vue')
    },

    // 梅花排盘
    {
      path: '/paipan/meihua',
      component: () => import('@/views/paipan/XuanMeiHuaViews.vue')
    },


    /* 关于 */

    // 关于本站
    {
      path: '/about',
      component: () => import('@/views/about/XuanAboutViews.vue')
    },

    // 隐私保护
    {
      path: '/privacy',
      component: () => import('@/views/about/XuanPrivacyViews.vue')
    },
    
    // 免责声明
    {
      path: '/disclaimer',
      component: () => import('@/views/about/XuanDisclaimerViews.vue')
    },


    /* 404 */

    {
      path: '/:catchAll(.*)',
      component: () => import('@/views/notfind/XuanNotFindViews.vue')
    }

  ]
})

// 全局前置守卫
router.beforeEach((to, from, next) => {
  window.scrollTo(0, 0); // 将滚动位置重置为顶部
  next(); // 跳转
})

// 全局解析守卫
router.beforeResolve((to, from, next) => {
  next(); // 跳转
})

// 全局后置守卫
router.afterEach((to, from) => {
  // next(); // 跳转
})

export default router;
